package semantic.rules.walk

import syntax.{CTerminal, CASTNode}
import scala.collection.mutable.Buffer
import utils.data.CTree
import semantic.COperations._
import lexis.CLexemeType._
import syntax.CGrammar._

object CWalkRuleIdentifier extends CWalkRule
{
    override val categories:Seq[CTerminal] = IDENTIFIER :: Nil

    override def post(node:CASTNode)(implicit tree:CTree[CASTNode], code:Buffer[String]) =
        if (node.parent.exists(_.category == CArithmeticExpression)) code += s"""$PUSH "${node.value}"""" += GET_VAR
}
